import Vue from 'vue';
//配置路由
import VueRouter from 'vue-router'
Vue.use(VueRouter);
//1.创建组件
import Index from '@/views/index'
import Home from '@/views/home'
import Login from '@/views/login'
import NotFound from '@/views/404'
import UpdatePassword from '@/views/update-password'
import pay from '@/views/pay'
import register from '@/views/register'
import center from '@/views/center'
import fangwuleixing from '@/views/modules/fangwuleixing/list'
import news from '@/views/modules/news/list'
import aboutus from '@/views/modules/aboutus/list'
import bianminfuwu from '@/views/modules/bianminfuwu/list'
import fankuiyijian from '@/views/modules/fankuiyijian/list'
import fuwuleixing from '@/views/modules/fuwuleixing/list'
import wuyerenyuan from '@/views/modules/wuyerenyuan/list'
import fangwuxinxi from '@/views/modules/fangwuxinxi/list'
import cheweixinxi from '@/views/modules/cheweixinxi/list'
import jiaofeixinxi from '@/views/modules/jiaofeixinxi/list'
import systemintro from '@/views/modules/systemintro/list'
import yonghu from '@/views/modules/yonghu/list'
import config from '@/views/modules/config/list'
import xiaoqufangke from '@/views/modules/xiaoqufangke/list'
import yonghubaoxiu from '@/views/modules/yonghubaoxiu/list'
import zhuangxiushenqing from '@/views/modules/zhuangxiushenqing/list'

//2.配置路由   注意：名字
const routes = [{
  path: '/index',
  name: '系统首页',
  component: Index,
  children: [{
    // 这里不设置值，是把main作为默认页面
    path: '/',
    name: '系统首页',
    component: Home,
    meta: { icon: '', title: 'center' }
  }, {
    path: '/updatePassword',
    name: '修改密码',
    component: UpdatePassword,
    meta: { icon: '', title: 'updatePassword' }
  }, {
    path: '/pay',
    name: '支付',
    component: pay,
    meta: { icon: '', title: 'pay' }
  }, {
    path: '/center',
    name: '个人信息',
    component: center,
    meta: { icon: '', title: 'center' }
  }
    , {
    path: '/fangwuleixing',
    name: '房屋类型',
    component: fangwuleixing
  }
    , {
    path: '/news',
    name: '小区活动',
    component: news
  }
    , {
    path: '/aboutus',
    name: '关于我们',
    component: aboutus
  }

    , {
    path: '/bianminfuwu',
    name: '便民服务',
    component: bianminfuwu
  }

    , {
    path: '/fankuiyijian',
    name: '投诉建议',
    component: fankuiyijian
  }

    , {
    path: '/fuwuleixing',
    name: '服务类型',
    component: fuwuleixing
  }
    , {
    path: '/wuyerenyuan',
    name: '物业人员',
    component: wuyerenyuan
  }
    , {
    path: '/fangwuxinxi',
    name: '住房信息',
    component: fangwuxinxi
  }

    , {
    path: '/xiaoqufangke',
    name: '小区访客',
    component: xiaoqufangke
  }

  , {
    path: '/yonghubaoxiu',
    name: '用户报修',
    component: yonghubaoxiu
  }

  , {
    path: '/zhuangxiushenqing',
    name: '装修申请',
    component: zhuangxiushenqing
  }

    , {
    path: '/cheweixinxi',
    name: '智能停车信息',
    component: cheweixinxi
  }
    , {
    path: '/jiaofeixinxi',
    name: '缴费信息',
    component: jiaofeixinxi
  }
    , {
    path: '/systemintro',
    name: '系统简介',
    component: systemintro
  }
    , {
    path: '/yonghu',
    name: '业主',
    component: yonghu
  }

    , {
    path: '/config',
    name: '轮播图管理',
    component: config
  }
  ]
},
{
  path: '/login',
  name: 'login',
  component: Login,
  meta: { icon: '', title: 'login' }
},
{
  path: '/register',
  name: 'register',
  component: register,
  meta: { icon: '', title: 'register' }
},
{
  path: '/',
  name: '系统首页',
  redirect: '/index'
}, /*默认跳转路由*/
{
  path: '*',
  component: NotFound
}
]
//3.实例化VueRouter  注意：名字
const router = new VueRouter({
  mode: 'hash',
  /*hash模式改为history*/
  routes // （缩写）相当于 routes: routes
})
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router;
